package com.chushouya.manager.constants;


import com.general.framework.core.enums.IEnum;
import com.general.framework.core.lang.Integers;
import com.general.framework.core.lang.Lists;
import org.apache.logging.log4j.util.Strings;

import java.util.List;
import java.util.Objects;

public enum PartnerTypeEnum implements IEnum<Integer> {

    // 业务员
    channel(1, "平台渠道"),
    partner(2, "合作商"),
    clerk(3, "业务员"),
    kefu(4, "客服"),
    franchisee(5, "加盟商"),
    cmcc(6, "移动门店"),
    //虚拟回收商
    offline_store(7, "线下门店"),;
    ;


    private Integer value;
    private String desc;

    PartnerTypeEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @Override
    public Integer value() {
        return this.value;
    }

    @Override
    public String named() {
        return this.desc;
    }

    public static String getDesc(Integer value) {
        for (PartnerTypeEnum thisEnum : PartnerTypeEnum.values()) {
            if (Objects.equals(thisEnum.value, value)) {
                return thisEnum.desc;
            }
        }
        return "";
    }

    public static String getPartnerUserTypeText(Integer partnerType) {
        if (Integers.isNullOrZero(partnerType)) {
            return Strings.EMPTY;
        }
        if(Objects.equals(PartnerTypeEnum.franchisee.value(), partnerType)){
            return ClerkUserTypeEnum.FRANCHISEE.named();
        } else if(Objects.equals(PartnerTypeEnum.cmcc.value(), partnerType)){
            return ClerkUserTypeEnum.CMCC_EMPLOYEE.named();
        }else{
            // 除开加盟商、移动店员，一律统称为业务员
            return ClerkUserTypeEnum.CLERK.named();
        }
    }

    public static ClerkUserTypeEnum getPartnerUserType(Integer partnerType) {
        if(Objects.equals(PartnerTypeEnum.franchisee.value(), partnerType)){
            return ClerkUserTypeEnum.FRANCHISEE;
        } else if(Objects.equals(PartnerTypeEnum.cmcc.value(), partnerType)){
            return ClerkUserTypeEnum.CMCC_EMPLOYEE;
        }else{
            // 除开加盟商、移动店员，一律统称为业务员
            return ClerkUserTypeEnum.CLERK;
        }
    }

    /**
     *         { label: '业务员', value: 3 },
     *         { label: '加盟商', value: 5 },
     *         { label: '移动店员', value: 6 },
     */
    public static List<Integer> getPartnerTypeList(Integer partnerUserType) {
        if(Objects.equals(PartnerTypeEnum.franchisee.value(), partnerUserType)){
            return Lists.asList(PartnerTypeEnum.franchisee.value());
        } else if(Objects.equals(PartnerTypeEnum.cmcc.value(), partnerUserType)){
            return Lists.asList(PartnerTypeEnum.cmcc.value());
        } else {
            return Lists.asList(
                    PartnerTypeEnum.channel.value(),
                    PartnerTypeEnum.partner.value(),
                    PartnerTypeEnum.clerk.value(),
                    PartnerTypeEnum.kefu.value()
            );
        }
    }
}
